﻿<div class="panel panel-primary">
    <div class="panel-heading"
         style="font-size: large">
        Списък със задачи
    </div>

    <div class="panel-body">
        <table class="table table-hover">

            <thead>
                <tr>
                    <td>#</td>
                    <td>Име</td>
                    <td>Описание</td>
                    <td ng-if="vm.currentUser.getProfile().isLoggedIn && vm.currentUser.getProfile().isAdmin">Тестове</td>
                    <td>Решения</td>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="task in vm.tasks" class="active">
                    <td>
                        {{ task.id }}
                    </td>
                    <td>{{ task.name }}</td>
                    <td>{{ task.description }}</td>
                    <td ng-if="vm.currentUser.getProfile().isLoggedIn && vm.currentUser.getProfile().isAdmin">
                        <input type="image" src="/images/add2.png" class="btn-custom" ng-click="vm.addTestDialog(task)">
                        <input type="image" src="/images/view.png" class="btn-custom" ng-click="vm.viewTests(task)">
                    </td>
                    <td>
                        <input type="image" src="/images/add2.png" class="btn-custom" ng-click="vm.openUpdateDialog(task)">
                        <input type="image" src="/images/view.png" class="btn-custom" ng-click="vm.viewSubmissions(task)">
                    </td>
                    <td ng-if="vm.currentUser.getProfile().isLoggedIn && vm.currentUser.getProfile().isAdmin">
                        <input type="image" src="/images/delete.png" class="btn-custom" ng-click="vm.deleteTask(task)">
                    </td>
                </tr>
            </tbody>
        </table>
        <button ng-if="vm.currentUser.getProfile().isLoggedIn && vm.currentUser.getProfile().isAdmin" type="button" class="btn btn-primary" ng-click="vm.addTaskEnabled = !vm.addTaskEnabled">Добави</button>
        <div uib-collapse="!vm.addTaskEnabled">
            <hr>
            <form name="addTaskForm" novalidate>
                <div class="form-group">
                    <div>
                        <label for="taskName">Име:</label>
                        <textarea class="form-control"
                                  rows="2"
                                  required
                                  id="taskName"
                                  ng-model="vm.taskToAdd.name"
                                  ng-maxlength="200"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div>
                        <label for="taskDescription">Описание:</label>
                        <textarea class="form-control"
                                  rows="5"
                                  required
                                  id="taskDescription"
                                  ng-model="vm.taskToAdd.description"></textarea>
                    </div>
                </div>
                <button class="btn btn-primary" type="button" ng-click="vm.addTask()" ng-disabled="addTaskForm.$invalid">Добави</button>
            </form>
        </div>
    </div>
</div>

